package com.hua.store.service.impl;

import com.hua.store.dao.CategoryDao;
import com.hua.store.dao.impl.CategoryDaoImpl;
import com.hua.store.domin.Category;
import com.hua.store.service.CategoryService;
import com.hua.store.utils.JedisUtils;
import redis.clients.jedis.Jedis;

import java.sql.SQLException;
import java.util.List;

public class CategoryServiceImpl implements CategoryService {
    @Override
    public List<Category> getAllCats() throws Exception {
        CategoryDao dao = new CategoryDaoImpl();
        return dao.getAllCats();
    }

    @Override
    public void addCategory(Category category) throws Exception {
        CategoryDao dao = new CategoryDaoImpl();
        dao.addCategory(category);
        Jedis jedis = JedisUtils.getJedis();
        jedis.del("cat");
        JedisUtils.closeJedis(jedis);
    }
}
